package com.qingcloud.fexecutor.base.enums;


import com.qingcloud.fexecutor.base.constant.RedisKeyPrefix;

/**
 * redis key 类型枚举
 *
 * @author yangfan
 * @date 2021/12/21 10:30
 */
public enum RedisCacheTypeEnum {
    /**
     * 设备信息
     */
    EQUIPMENT_INFO(1, RedisKeyPrefix.PROJECT_NAME+RedisKeyPrefix.DIRECTORY_SPLIT+"EQUIPMENT_INFO",new String[]{"equipmentId"},"设备信息"),
    /**
     * 产品指令信息
     */
    PRODUCT_COMMAND_INFO(4, RedisKeyPrefix.PROJECT_NAME+RedisKeyPrefix.DIRECTORY_SPLIT+"PRODUCT_COMMAND_INFO",new String[]{"id"},"产品指令信息"),

    /**
     * 设备状态信息
     */
    EQUIPMENT_STATUS_INFO(5, RedisKeyPrefix.PROJECT_NAME+RedisKeyPrefix.DIRECTORY_SPLIT+"EQUIPMENT_STATUS_INFO",new String[]{"equipmentId","channelId"},"设备状态信息"),


    /**
     * 缓存元数据
     */
    METADATA(5, RedisKeyPrefix.PROJECT_NAME+RedisKeyPrefix.DIRECTORY_SPLIT+"METADATA",new String[]{"cacheType"},"缓存元数据"),

    ;

    /**
     * 缓存代码
     */
    private final Integer cacheKeyCode;

    /**
     * 缓存类型
     */
    private final String cacheType;

    /**
     * redis查询key
     */
    private final String[] redisQueryKey;

//    /**
//     * 缓存对应实体class类型
//     */
//    private final Class<?> entityClass;

    /**
     * 描述
     */
    private final String message;

    RedisCacheTypeEnum(Integer cacheKeyCode, String cacheType, String[] redisQueryKey, String message){
        this.cacheKeyCode = cacheKeyCode;
        this.cacheType = cacheType;
        this.redisQueryKey = redisQueryKey;
        this.message = message;
    }

    public static RedisCacheTypeEnum getByCode(Integer code) {
        for (RedisCacheTypeEnum redisCacheTypeEnum : RedisCacheTypeEnum.values()) {
            if (redisCacheTypeEnum.getCacheKeyCode().equals(code)) {
                return redisCacheTypeEnum;
            }
        }
        return null;
    }


    public Integer getCacheKeyCode() {
        return cacheKeyCode;
    }

    public String getCacheType() {
        return cacheType;
    }

    /**
     * 得到缓存对应实体class类型
     * @return 缓存对应实体class类型
     */
//    public Class<?> getEntityClass() {
//        return entityClass;
//    }

    /**
     * 得到redis查询key
     * @return redis查询key
     */
    public String[] getRedisQueryKey() {
        return redisQueryKey;
    }

    public String getMessage() {
        return message;
    }

}
